<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="token-tag" prefix="t"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/pad/common/commonCss.jsp" />
<jsp:include page="/pad/common/commonJs.jsp" />
<script type="text/javascript"
	src="${basePath }commonJs/quinn_commons.js"></script>
<script type="text/javascript"	src="${basePath}pad/commonJs/tags/My97DatePicker/WdatePicker.js"></script>
<script  type="text/javascript" src="${basePath}pad/commonJs/jt_map.js"></script>
<script type="text/javascript">
//当前的数量
var currentCount = null;

var isZdzk = false;

var zdzk_value = 1;

var zdzk_id = null;

var manager = null;
var discountMap = new HashMap();
var isContinueProduct=true,isContinueOrder=true;
$(document).ready(function() {
		showData();
		   /**滚屏加载商品列表的信息*/
	   	$("#ul1").scroll(function(){  
		    	  if($("#ul1")[0].scrollTop >= ($("#ul1")[0].scrollHeight - $("#ul1").height())){
		    		  if(isContinueProduct==true){
		    			  $("#pageNoForProduct").val(parseInt($("#pageNoForProduct").val())+1);
			    		  showData();
		    		  }else{
		    			  alertWarning("已经到底了!");
		    		  } 
		    	  }
		});
	   /**下滑显示订单列表的详细信息*/
		$("#orderFlow").scroll(function(){  
	  	  if($("#orderFlow")[0].scrollTop >= ($("#orderFlow")[0].scrollHeight - $("#orderFlow").height())){
	  		   if(isContinueOrder==true){
	  			  $("#pageNoForOrder").val(parseInt($("#pageNoForOrder").val())+1);
		    		 showOrderData();
	  		  }else{
	  			  alertWarning("已经到底了!");
	  		  }
	  	  }
	});
	});
 function showData() {
		$.ajax({
			url:"${basePath}goods/paginate.shtml",
			dateType:"json",
			data:$("#form1").serialize(),
			type:"post",
			error : function(XMLHttpRequest) {
	 				ajaxError(XMLHttpRequest);
	 			},
			success:function(data){
				cb(data.results);
			}
		});
	} 
	function cb(data) {
		if(data==null||data.length==0){
			isContinueProduct=false;
		}else{
			$ .each( data, function(ind, obj) {
								obj = emptyJson(obj);
								var disValue = 1;
								if (obj.disValue != null && parseFloat(obj.disValue) > 0) {
									disValue = obj.disValue;
								}
								var li ="<li><img   width='216' height='216'   src=\"${basePath}common/getImageByAttfile.shtml?attfileId=" + obj.fkPicFile + "\"  class=\"m10\">";
								li+="<div class=\"consumen\">";
								li+="<p> <span class=\"sp\" title=\""+obj.prdName+"  "+obj.prdSpec+"\">";
								li+=obj.prdName+" "+obj.prdSpec;
								li+="</span> <span class=\" color_lv f18\">￥"+obj.productPrice * disValue+"</span><span class=\"color_9c9 ml10\">(库存：";
								li+="<span id=\"kc_"+obj.pkPrdId+"\">" + (obj.stgCnt == "" ? 0 : obj.stgCnt) + "</span>";
								li+=")</span></p>";
								li+="<p class=\"tc\"><a   onmouseover=\"this.style.cursor='hand'\"    class=\"icon iconfont ml10\"  onclick=\"javascript:jian('"+ obj.pkPrdId+ "')\">&#xe611;</a>";
								li+="<input type=\"text\" class=\"iput_t w50 ml10\"   value=\"0\"   id=\"productCount"+ obj.pkPrdId	+ "\"  onchange=\"changeCount('"+ obj.pkPrdId + "');\" >";
								li+="<a   onmouseover=\"this.style.cursor='hand'\"    class=\"icon iconfont\"  onclick=\"javascript:jia('"+ obj.pkPrdId+ "')\">&#xe610;</a>";
								li+=" <input type=\"button\" class=\"btn vt w50 ml10\" value=\"购买\"  onclick=\"buy('"+ obj.pkPrdId + "')\">";
								li+="</p> </div></li>";
								$("#ul1").append(li);
				});
		}	
	}
	function  search(){
		$("#pageNoForProduct").val("1"); 
		$("#prdName").val($("#seachprd").val());
		$("#ul1 li").remove();
		showData();
	}

	function jian(id) {
		var v = $("#productCount" + id).val();
		if (parseInt(v) > 0) {
			$("#productCount" + id).val(parseInt(v) - 1);
		}
	}

	function jia(id) {
		var v = $("#productCount" + id).val();
		if (validateCount(id, parseInt(v) + 1)) {
			$("#productCount" + id).val(parseInt(v) + 1);
		}
	}
	/**购物篮加数量*/
	function jianForShop(id) {
		var v = $("#input_c_" + id).val();
		if (parseInt(v) <= 0) {
			alertInfo("数量已经为0了!");
			return;
		}
		$("#input_c_" + id).val(parseInt(v) - 1);
		modifyGoodsStgCnt(id, 1, null);
		updateXJ(id);
		changeDiscountPrice(id);
		changeAllPrice();
	}

	function jiaForShop(id) {
		var v = $("#input_c_" + id).val();
		var isOk = false;
		$.ajax({
			url : "${basePath}order/getProductCount.shtml",
			type : "post",
			dataType : "json",
			async : false,
			data : {
				productId : id
			},
			success : function(data) {
				if (parseInt(v) + 1 > data) {
					alertInfo("库存已不足!");
				} else {
					modifyGoodsStgCnt(id, -1, null);
					isOk = true;
				}
			},
			error : function(XMLHttpRequest) {
				ajaxError(XMLHttpRequest);
			}
		});

		if (isOk)
			$("#input_c_" + id).val(parseInt(v) + 1);
		updateXJ(id);
		changeDiscountPrice(id);
		changeAllPrice();
	}

	

	function validateCount(id, num) {
		var n = $("#kc_" + id).html();
		if (parseInt(n) < num) {
			alertInfo("库存已不足");
			return false;
		}
		return true;
	}

	function changeCount(id) {
		var n = $("#productCount" + id).val();
		if (isNaN(n)) {
			alertInfo("输入不合法");
			$("#productCount" + id).val(0);
			return;
		}
		if (!validateCount(id, parseInt(n))) {
			$("#productCount" + id).val(0);
		}
	}

	function buy(id) {
		var c = $("#patry").attr("checked") == "checked";
		var p = null;
		if (c) {
			p = $("#pdId").val();
		}
		var shopCartId = $("#shopCartId").val();

		var cou = $("#productCount" + id).val();

		if (isNaN(cou)) {
			alertInfo("数量不合法");
			$("#productCount" + id).val(0);
			return;
		}

		if (parseInt(cou) < 1) {
			alertInfo("购买数量至少为1");
			return;
		}

		var params = {
			isParty : c,
			partyId : p,
			productId : id,
			shopCartId : shopCartId,
			count : cou
		};

		$.ajax({
			url : "${basePath}goods/put2Order.shtml",
			type : "post",
			dataType : "text",
			data : params,
			success : function(data) {
				if (data != null) {
					$("#shopCartId").val(data);
					modifyGoodsStgCnt(id, -parseInt(cou), null);
					var no = $("#kc_" + id).html();
					$("#kc_" + id).html(parseInt(no) - parseInt(cou));
					alertInfo("操作成功");
					showData();
				}
			},
			error : function(XMLHttpRequest) {
				ajaxError(XMLHttpRequest);
			}
		});
	}
	/*更新商品库存信息**/
	function modifyGoodsStgCnt(id, count, suc) {

		$.ajax({
			url : "${basePath}goods/modifyGoodsStgCnt.shtml",
			type : "post",
			dataType : "json",
			data : {
				productId : id,
				count : count,
				orderId : ""
			},
			async : false,
			success : function(data) {
				if (suc != null)
					suc();
			},
			error : function(XMLHttpRequest) {
				ajaxError(XMLHttpRequest);
			}
		});
	}
	/*显示购物篮的信息*/
	function showCartData(){
		$.ajax({
			url : "${basePath}order/shopCartForPad.shtml",
			type : "post",
			dataType : "json",
			data : {
				shopCartId : $("#shopCartId").val()
			},
			async : false,
			success : function(data) {
				publicMethod(data);
			}
		});
	}
	function publicMethod(data){
		var order=data.order;
		trimJson(order);
		var loginUser=data.loginUser;
		var products=data.products;
		trimJsonArray(products);
		var html;
		if(order!=null){
			html='<li><label>订单号：</label>'+order.pkOrderId+'<input type="hidden" value="'+order.pkOrderId+'" id="pkOrderId"></li>';
			html+='<li><label>客户姓名：</label>'+order.operator+'</li>';
			html+='<li><label>当前操作人：</label>'+loginUser.name+'</li>';
			html+='<li>'+loginUser.branName+'</li>';
			var button;
			if(order.orderStatus=="4"){
				button="<input type='button' class='btn' value='继续购物' onclick=\"javascript:window.location.href='${basePath}goods/padSales.shtml'\">";
				if(products!=null&&products.length!=0){
					button+='<input type="button" class="btn ml10" value="确认" 	onclick="subForm();">';
					button+='<input type="button" class="btn ml10" value="取消"	onClick="cancel();">';
				}
				$("#buttonPerssion").html(button);
			}else{
				button="<input type=\"button\" class=\"btn ml10\" value=\"返回\" 	onClick=\"javascript:window.location.href='${basePath}goods/padSales.shtml'\">";
				$("#buttonPerssion").html(button);
			}
		}else{
			html='<li><label>订单号：</label></li>';
			html+='<li><label>客户姓名：</label></li>';
			html+='<li><label>当前操作人：</label>'+loginUser.name+'</li>';
			html+='<li>'+loginUser.branName+'</li>';
		}
		$("#orderInfo").html(html);
		showProductInfo(products,order);
		var discounts=data.discounts;
		trimJsonArray(discounts);
		//计算所有商品的总价
		changeAllPrice();
	}
	/**更改样式*/
	function  changeTheStyle(Flag){
		var now=$(".thistab_a");
		if(Flag=="orderLi"){
			now.prev().addClass("thistab_a");
			now.removeClass("thistab_a");
			$("#orderLi").attr("style","display:none");
			$("#shopCardLi").attr("style","");
		}else{
			now.next().addClass("thistab_a");
			now.removeClass("thistab_a");
			$("#orderLi").attr("style","");
			$("#shopCardLi").attr("style","display:none");	
		}
	}
	/*链接显示订单状态位购物车的的详细信息*/
	function  linkData(shopCartId){
		changeTheStyle("orderLi");
		/**/
		$.ajax({
			url : "${basePath}order/shopCartForPad.shtml",
			type : "post",
			dataType : "json",
			data : {
				shopCartId : shopCartId
			},
			async : false,
			success : function(data) {
				publicMethod(data);
			}
		});
	}
	/*显示订单的详细信息**/
	function detailData(shopCartId){
		 window.location.href="${basePath}order/orderDetailForPad.shtml?id="+shopCartId+"";
	}
	function showProductInfo(products,order){
		 var html='<tr><th>商品编码</th><th>商品名称</th><th>数量</th>';
		 html+='<th>单价</th><th>小计</th><th>折扣率</th><th>备注</th><th>折后金额</th><th>操作</th></tr>';
		if(products==null){
			html+='<tr><td colspan="9" align="center"><span style="color: red;">当前还未选择任何商品，请点击按钮‘继续购物’回到购物页面</span></td></tr>';
		}else{
			$(products).each(function(id,item){
				html+="<tr id='tr_"+item.fkPrdId+"'><td>"+item.fkPrdId+"</td>";
				html+="<td>"+item.productName+"</td>";
				if(item.prdCateId=="001003"||item.prdCateId=="001004"){
					html+="<td>"+item.count+"</td>";
				}else{
					html+="<td class='consumer'><a   class='icon iconfont'  onclick=\"javascript:jianForShop('"+item.fkPrdId+"');\">&#xe611;</a>";
					html+="<input type='text' class='iput_t w50' id='input_c_"+item.fkPrdId+"'    value='"+item.count+"'  ";
					html+="onclick='currentc(this)' onblur=\"checkCount(this,'"+item.fkPrdId+"');\" >";
					html+="<a   class='icon iconfont'  onclick=\"javascript:jiaForShop('"+item.fkPrdId+"');\">&#xe610;</a></td>";
				}
				html+='<td>'+item.price+'</td>';
				html+='<td><span id="span_xj_'+item.fkPrdId+'">'+(item.price*item.count)+'</span></td>';
				html+='<td><span id="span_'+item.fkPrdId+'">-</span>';
				if(item.allowSpedis!="0"){
					html+='<input type="button" class="btn_l" value="特殊折扣" onClick="openWindow("'+item.fkPrdId+'");"></td>';
				}else{
					html+="</td>";
				}
				html+='<td><input type="text" class="iput_t" placeholder="备注信息"></td>';
				html+='<td>'+(item.price*item.count)+'</td>';
				html+="<td class='consumer'><a href=\"javascript:delPrd('"+item.fkPrdId+"');\" class='icon iconfont'>&#xe60e;</a></td></tr>";
			});
			if(products!=null){
				html+='<tr><td colspan="10"><ul class="goods_ul fr p10">';
				html+='<li>商品总价：<span class="color_lv mlr5 f18">￥<span id="spzj"></span></span></li>';
				html+='<li>已付金额：<span class="color_lv mlr5 f18">￥<span id="yifje">'+(order.paidAmount==null||order.paidAmount==""?0:order.paidAmount)+'</span></li>';
				html+='<li>整单折扣：<span class="color_lv mlr5 f18"><span id="zdzk">-</span></span></li>';
				html+='<li>折扣金额<span class="color_lv mlr5 f18">￥<span id="zkje">0</span></span></li>';
				html+='<li>应付金额<span class="fb mlr5 color_org f18">￥<span	id="yingfje">200</span></span></li>';
				html+='<li><input type="button" onclick="zddz();" value="整单打折"	class="btn fl"></li></ul></td></tr>';
			}
		}
		$("#table1").html(html);
	}
	function searchOrderData(){
		//$("#orderFlow").height(330);
		$("#pageNoForOrder").val("1");
		$("#orderData").html("");
		showOrderData();
	}
	/*显示订单的信息*/
	function showOrderData(){
		var orderStatus=$("#orderStatus").val();
		var pkOrderId=$("#input_pkOrderId").val();
		var  pageNoForOrder=$("#pageNoForOrder").val();
		var  pageSizeForOrder=$("#pageSizeForOrder").val();
		$.ajax({
			url : "${basePath}order/findOrderList.shtml",
			data : {
				orderStatus : orderStatus,
				pkOrderId:pkOrderId,
				pageSize:pageSizeForOrder,
				pageNo:pageNoForOrder
			},
			type : "post",
			dataType : "json",
			async : false,
			success : function(data) {
				parseOrderData(data);
			}
		});
	}
	/*整单打折*/
	function executeDiscount() {

		manager = null;

		var password = $("#mg_password").val();
		var disc = $("#discount_select").val();
		if (disc.length == 0) {
			alertInfo("请选择折扣");
			return;
		}
		var txt = $("#discount_select option:selected").text();

		var orderPrdId = $("#orderPrdId").val();

		$.ajax({
			url : "${basePath}common/validateManager.shtml",
			data : {
				password : password
			},
			type : "post",
			dataType : "json",
			async : false,
			success : function(data) {
				if (data != null) {
					manager = data.pkUsrId;
				}
			},
			error : function(XMLHttpRequest) {
				ajaxError(XMLHttpRequest);
			}
		});

		if (manager == null) {
			alertInfo("密码输入错误或不存在!");
			return;
		}

		var v_i = disc.split("_");

		if (isZdzk) {
			$("#zdzk").html(txt);
			zdzk_value = parseFloat(v_i[0]);
			zdzk_id = v_i[1];
			$("#table1 tr:not(:first,:last)").each(
					function() {
						$(this).find("td:eq(5) span").html("-");
						$(this).find("td:eq(7)").html(
								$(this).find("td:eq(4) span").html());
					});
			$("#fkDisId").val(zdzk_id);
			changeAllPrice();
			discountMap = new HashMap();
		} else {

			$("#fkDisId").val(null);
			var dis = {};
			dis.id = v_i[1];
			dis.value = v_i[0];

			$("#span_" + orderPrdId).html(txt);
			$("#zdzk").html("-");
			$("#zkje").html("0");
			zdzk_value = 1;

			discountMap.put(orderPrdId, dis);
			changeDiscountPrice(orderPrdId);
			changeAllPrice();
		}
		closeWindow();
	}
	function closeWindow() {
		$('#e').window('close');
		$("#discount_select option:selected").attr("selected", false);
		$("#orderPrdId").val(null);
		$("#mg_password").val(null);
		$("#discount_select").val(null);
		isZdzk = false;
	}
	/**计算商品的总价*/
	function changeAllPrice() {
		updateTotalPrice();
		changeZkje();
		var spzj = $("#spzj").html();
		var yifje = $("#yifje").html();
		var zkje = $("#zkje").html();
		var allzhje = 0;
		$("#table1 tr:not(:first,:last)").each(function() {
			var f = $(this).find("td:eq(7)").html();
			allzhje += parseFloat(f);
		});
		allzhje = allzhje * zdzk_value;
		$("#yingfje").html(allzhje.toFixed(2));
	}
	function updateTotalPrice() {
		var price = 0;
		$("#table1").find("tr:not(:first,:last)").each(function() {
			var p = $(this).find("td:eq(4)").find("span").html();
			price += parseFloat(p);
		});
		$("#spzj").text(price.toFixed(2));
	}
	function changeZkje() {
		var spzj = $("#spzj").html();
		if (zdzk_value != 1)
			$("#zkje").html(
					(parseFloat(spzj) - parseFloat(spzj) * zdzk_value)
							.toFixed(2));
		else
			$("#zkje").html(0);
	}
	function updateXJ(id) {
		var tr = $("#tr_" + id);
		var num = tr.find("td:eq(2)").find("input").val();
		var price = tr.find("td:eq(3)").html();
		var xj = parseInt(num) * parseFloat(price);
		$("#span_xj_" + id).text(xj.toFixed(2));
	}
	
	function changeDiscountPrice(id) {
		var o = discountMap.get(id);
		var zkl = o == null ? 1 : parseFloat(o.value);
		var xj = $("#span_xj_" + id).html();
		var v = parseFloat(xj) * zkl;
		$("#tr_" + id).find("td:eq(7)").html(v.toFixed(2));
	}
	
	function currentc(o) {
		var v = $(o).val();
		if (v != null && v.length > 0) {
			currentCount = parseInt(v);
		}
	}
	function checkCount(o, id) {
		var val = $(o).val();
		if (isNaN(val)) {
			alertInfo("数量只能为数字!");
			$(o).val(0);
		}
		$.ajax({
			url : "${basePath}order/getProductCount.shtml",
			type : "post",
			dataType : "json",
			async : false,
			data : {
				productId : id
			},
			success : function(data) {
				var thisv = parseInt(val);
				if (thisv > data) {
					alertInfo("库存不足,该商品当前最大库存为" + data + ",请重新填写数量!");
					$(o).val(currentCount);
					return;
				}
				if (currentCount != null) {
					modifyGoodsStgCnt(id, currentCount - thisv, null);
				}
			},
			error : function(XMLHttpRequest) {
				ajaxError(XMLHttpRequest);
			}
		});

		updateXJ(id);
		changeDiscountPrice(id);
		changeAllPrice();
		currentCount = null;
	}
	/**删除订单中的商品*/ 
	function delPrd(id) {
		$.messager.confirm("INFO", "确认要删除吗?", function(r) {
			if (r) {
				$.ajax({
					url : "${basePath}goods/removeOrderPrd.shtml",
					type : "post",
					dataType : "json",
					data : {
						orderId : $("#pkOrderId").val(),
						productId : id
					},
					success : function(data) {
						if (data) {
							$("#tr_" + id).remove();
						}
						changeAllPrice();
					},
					error : function(XMLHttpRequest) {
						ajaxError(XMLHttpRequest);
					}
				});
			}
		})
	}
	/*下排按钮操作*/
	function subForm() {
		if (checkForm()) {
			var prds = [];
			$("#table1 tr:not(:first,:last)").each(function() {
				var id = $(this).find("td:eq(0)").html();
				var no = $(this).find("td:eq(2)").find("input:text").val();
				var remark = $(this).find("td:eq(6)").find("input:text").val();
				var dis = discountMap.get(id);
				var prd = id;
				prd += "_" + no;
				if (dis != null) {
					prd += "_" + dis.id;
				} else {
					prd += "_" + 0;
				}
				prd += "_" + remark;

				prds.push(prd);
			});
			$("#values").val(prds.toString());
			var tre = $("#t_remark").val();
			$("#u_remark").val(tre);
			$("#pkOrderId").val($("#orderId").val());
			$("#AMOUNT").val($("#spzj").html());
			$("#fkDisusrId").val(manager);
			$.ajax({
				url:"${basePath }order/updateOrderForPad.shtml",
				type:"post",	
				dataType:"json",
				data:$("#updateform").serialize(),
				async:false,
				success:function(result){
					changeTheStyle("shopCardLi");
					searchOrderData();
				},error : function(XMLHttpRequest) {
					ajaxError(XMLHttpRequest);
				}
			});
		}
	}
	function checkForm() {
		var flag = true;
		$("#table1 tr:not(:first,:last)").each(function() {
			var no = $(this).find("td:eq(2)").find("input:text").val();
			var remark = $(this).find("td:eq(6)").find("input:text").val();
			if (isNaN(no)) {
				alertInfo("商品数量只能为数字!");
				flag = false;
				return false;
			}

			if (remark.indexOf("_") > 0) {
				alertInfo("备注不允许出现特殊字符!");
				$(this).find("td:eq(6)").find("input:text")[0].focus();
				flag = false;
				return false;
			}
			if (remark.length > 25) {
				alertInfo("请控制在25个字符以内!");
				$(this).find("td:eq(6)")[0].focus();
				flag = false;
				return false;
			}
		});

		return flag;
	}
	function cancel() {
		$.messager
				.confirm(
						"提示",
						"确认要取消该订单吗",
						function(r) {
							if (r) {
								window.location.href = '${basePath}order/cancelOrder.shtml?id=${order.pkOrderId }';
							}
						});
	}
	function zddz() {
		isZdzk = true;
		$('#e').window('open');
	}
	
	function parseOrderData(data){
		if(data!=null){
			trimJsonArray(data);
			$.each(data,function(ind,obj){
				var os ="";
				if(obj.orderStatus=="1"){
					os="未付款";
				}else if(obj.orderStatus=="2"){
					os="已付款";
				}else if(obj.orderStatus=="3"){
					os="已预付";
				}else if(obj.orderStatus=="4"){
					os="购物车";
				}else if(obj.orderStatus=="5"){
					os="取消";
				}else if(obj.orderStatus=="6"){
					os = "已预付";
				}else if(obj.orderStatus=="7"){
					os = "草稿";
				}
				
				var link ="";
				
				if(obj.orderStatus=="4"){
					link="linkData('"+obj.pkOrderId+"')";
				}else{
					link="detailData('"+obj.pkOrderId+"')";
				}
				var button = "";
				if(obj.orderStatus=="1" || obj.orderStatus=="4"){
					button = "<input type=\"button\" value=\"取消\" class=\"btn_l \" onclick=\"cancelOrder('"+obj.pkOrderId+"')\">";
				}else if(obj.orderStatus=="2"&&(obj.orderType=="1"||obj.orderType=="5")){
					button = "<input type=\"button\" value=\"退货\" class=\"btn_l \">";
				}else{
					button="";
				}
				var paymethod = "";
				var payTime = "";
				if(obj.orderStatus=="1"||obj.orderStatus=="4"){
					paymethod="-";
					payTime="-";
				}else{
					paymethod=obj.payMethod;
					payTime = obj.time2;
				}
				var trHtm="<tr>";
				trHtm+="<td class=\"lv\"><a onclick=\""+link+"\" >"+obj.pkOrderId+"</a></td>";
				trHtm+="<td>普通商品</td>";
				trHtm+="<td>￥"+obj.amount+"</td>";
				trHtm+="<td>"+paymethod+"</td>";
				trHtm+="<td>"+payTime+"</td>";
				trHtm+="<td>"+obj.cusName+"</td>";
				trHtm+="<td>"+obj.operator+"</td>";
				trHtm+="<td>"+os+"</td>";
				trHtm+="<td>"+button+"</td>";
				/* if(obj.orderStatus!="3"){
					trHtm+="<td>"+button+"</td>";
				} */
				trHtm+="</tr>";
				$("#orderData").append(trHtm);
			});
			/*  if($("#pageNoForOrder").val()>1){
				 var  $orderFlow=$("#orderFlow");
				 $orderFlow.height($orderFlow.height()+700);
			 } */
		}else{
			isContinueOrder=false;
			$("#orderData").html('<tr><td colspan="9" align="center"><span style="color: red;">没有搜索到相关记录</span></td></tr>');
		}
	}
	/**取消订单*/
	function cancelOrder(id){
		$.messager.confirm("提示", "确认要取消吗?", function(flag){
			if(flag==true){
				$.ajax({
					url:"${basePath}order/cancelOrderAjax.shtml",
					type:"post",
					dataType:"json",
					data:{
						id:id
					},async:false,
					success:function(data){
						if(data){
							searchOrderData();
						}
					},error : function(XMLHttpRequest) {
						ajaxError(XMLHttpRequest);
					}
				});
			}
		});
	}
</script>
<title>商品列表</title>
</head>
<body class="bg">
	<form action="${basePath }goods/paginate.shtml" id="form1"
		method="post">
		<input type="hidden" name="pageSize" value="10"> <input
			type="hidden" name="pageNo" value="1" id="pageNoForProduct"> <input type="hidden"
			name="fkPrdcateId" value="${cate.pkPrdcateId}" id="cateId">
		<input type="hidden" name="prdName" id="prdName">
	</form>
	<form action="" method="post"
		id="updateform">
		<t:token />
		<input type="hidden" name="pkOrderId"  id="orderId">
		<input type="hidden" name="values" id="values"> <input
			type="hidden" name="comments" id="u_remark"> <input
			type="hidden" name="fkDisId" id="fkDisId"> <input
			type="hidden" name="amount" id="AMOUNT"> <input type="hidden"
			name="fkDisusrId" id="fkDisusrId">
	</form>
	
	<!-- 订单id -->
	<input type="hidden" id="shopCartId" value="${shopCartId}">
	<!-- 订单分页 -->
	<input type="hidden" id="pageSizeForOrder" value="10">
	<input type="hidden" id="pageNoForOrder" value="1">
	<div class="i_index">
		<div class="i_index_l fl">
			<h1><a href="${basePath}system/user/updatePadPass.shtml"><i class="icon iconfont">&#xe60f;</i><br>${user.name}</a></h1>
	        <ul>
	        	<li><a href="${basePath }system/index.shtml?mode=pad"><i class="icon iconfont">&#xe600;</i><br>首页</a></li>
	            <li><a href="${basePath}filemanagement/findVipInfo.shtml"><i class="icon iconfont">&#xe603;</i><br>会籍</a></li>
	            <li><a href="${basePath}parreserve/reservationPage.shtml"><i class="icon iconfont">&#xe604;</i><br>预约</a></li>
	            <li  class="i_index_l_hover"><a href="${basePath }goods/padSales.shtml"><i class="icon iconfont">&#xe602;</i><br>消费管理</a></li>
	        </ul>
		</div>
		<div class="i_index_r fl oh">

			<ul id="tab_d" class="i_index_tab m20 fixed">
				<li class="border_radius_l thistab_a" onclick="search();">商品列表</li>
				<li  onclick="showCartData();">购物篮</li>
				<li  onclick="searchOrderData();" 	class="border_radius_r">订单管理</li>
			</ul>
			<div class="clear"></div>
			<div class="tc">
				<input type="checkbox" class="mr5" id="patry">派对
				<div class="uboxstyle">
					<select name="language_ax" id="pdId">
							<c:forEach items="${reserves }" var="re">
											<option value="${re.pkParresId }">${re.subject }</option>
							</c:forEach>
					</select>
				</div>
			</div>
			<div class="clear"></div>
			<ul id="tab_conbox_d">
				<li>
					<!-- 内容 -->
					<div class="goods_ware fixed mt20">
						<ul class="goods_ware_ul">
							<li>
								<dl class="goods_ware_dl">
									<c:forEach items="${higherCates}" var="cat">
										<dd>
											<a
												href="${basePath}goods/padSales.shtml?cateId=${cat.pkPrdcateId }" title="${cat.cateName}">
												
												<c:choose>
													<c:when test="${fn:length(cat.cateName)>9}">
															${fn:substring(cat.cateName,0,9)}...
													</c:when>
													<c:otherwise>
															${cat.cateName}
													</c:otherwise>
												</c:choose>	
												</a>
										</dd>
										<dd>&gt;</dd>
									</c:forEach>
								</dl>
							</li>
							<li class="fr"><input type="text" class="iput_t w200" id="seachprd"><input
								type="button" class="btn ml10 vt" value="搜 索" onclick="search();"></li>
						</ul>
					</div>
					<div>
						<div class="caidan_l">
							<dl>
								<dt>
									<i class="icon iconfont lv_icon mr5">&#xe61c;</i>${cate.cateName}
								</dt>
								<c:forEach items="${lowerCates }" var="cat">
									<dd
										onclick="window.location.href='${basePath}goods/padSales.shtml?cateId=${cat.pkPrdcateId }'" title="${cat.cateName }">
										<c:choose>
													<c:when test="${fn:length(cat.cateName)>9}">
															${fn:substring(cat.cateName,0,9)}...
													</c:when>
													<c:otherwise>
															${cat.cateName}
													</c:otherwise>
										</c:choose>	
									</dd>
								</c:forEach>

							</dl>
						</div>
						<ul class="goods_ware_ulx" id="ul1"  style="height:658px; overflow-y:auto;">
						</ul>
					</div>
					<!-- <div class="page fr m10" id="foot1">
					</div> 内容 -->
				</li>
				<li style="display: none" id="shopCardLi">
					<!-- 内容 -->
					<div class="p20">
						<div class="goods_order_top fixed mt10 f14">
							<ul class="ml10" id="orderInfo">
								
							</ul>
						</div>
						<table class="table mt10" id="table1">
						
						</table>
						<textarea style="width: 872px; margin-top: 10px;" 	placeholder="备注信息" class="textare" id="t_remark"></textarea>
						<div class="fr mt10" id="buttonPerssion">
							
						</div>
					</div> <!-- 内容 -->
				</li>
				<li style="display: none" id="orderLi">
					<!---内容--->
					<div class="p20">
						<dl class="consum_dll">
							<dd>
								<label>订单：</label>
								<!----select--->
								<div class="uboxstyle">
									<select name="language_axx" id="orderStatus">
										<option value="">全部</option>
										<option value="4">购物车</option>
										<option value="1">未付款</option>
										<option value="6">已预付</option>
										<option value="2">已付款</option>
									</select>
								</div>
								<!----select--->
							</dd>
							<dd class="fr">
								<input type="text" class="iput_t w200" placeholder="搜索订单号"  id="input_pkOrderId"><input
									type="button" value="搜 索" class="btn ml10"  onclick="searchOrderData();" >
							</dd>
						</dl>
						<div class="clear"></div>
						<div class="tab_normal mt10">
						  <div id="scrollTable">
						  			<!-- 头部 -->
						  			<table class="table">
									    	<colgroup>
									    	<col width="120px">
									        <col width="70px">
									        <col width="100px">
									        <col width="150px">
									        <col width="150px">
									        <col width="70px">
									        <col width="70px">
									        <col width="70px">
									        <col>
									        </colgroup>
        									<tbody>
        										<tr><th>订单</th>
										        <th>商品类型</th>
										        <th>金额</th>
										        <th>付款方式</th>
										        <th>交易时间</th>
										        <th>顾客信息</th>
										        <th>操作员</th>
										        <th>订单状态</th>
										        <th>操作</th>
    											</tr>
    										</tbody>
    									</table>
    									<!-- content -->
    									<div id="orderFlow">
       										 <table class="table">
		       										<colgroup>
		       											 <col width="120px">
												        <col width="70px">
												        <col width="100px">
												        <col width="150px">
												        <col width="150px">
												        <col width="70px">
												        <col width="70px">
												        <col width="70px">
												        <col>
		       									 </colgroup>
		       									 <tbody id="orderData">
		       		
		       									 </tbody>
       								</table>
    							</div>
						  
						  </div>
						</div>
					</div> 
				</li>
				<li style="display: none">4</li>
			</ul>
		</div>
	</div>
	<!---弹出层--->
	<div id="e" class="easyui-window" title="特殊折扣设置"
		data-options="modal:true,closed:true,iconCls:'icon-save'"
		style="width: 500px; height: 300px; position: relative;">
		<div class="margin_auto w320 pt30">
			<ul class="ul_label f14">
				<li><label>折扣率：</label>
					<div class="uboxstyle">
						<select name="language_a" id="discount_select">
							<option value="">请选择</option>
							<c:forEach items="${discounts }" var="dis">
								<option value="${dis.disValue }_${dis.pkDisId}">${dis.disDesc }</option>
							</c:forEach>
						</select>
					</div></li>
				<li><label>经理密码：</label><input type="password" class="iput_t w200" id="mg_password"></li>
				
			</ul>
		</div>
		<div class="btm_btn btm_bg">
			<dl>
				<dd>
					<input type="button" class="btn" onClick="executeDiscount();" value="确定">
				</dd>
				<dd>
					<input type="button" class="btn" onClick="closeWindow();" 	value="取消">
				</dd>
			</dl>
		</div>
	</div>
</body>
</html>
